#include "stdafx.h"
#include "CScrLanguage.h"

CList<CLabel>			CLabels::s_pLabelList;
CLListEx<CLabel*>		CLabels::s_pLabelLinks;
int						CLabels::s_nNumLabels;

bool CLabels::LoadFromFile(const char *szFilePath)
{
	if(FILE *hFile = OpenFile(szFilePath, "rt"))
	{
		while(char *szStr = GetConfigLine(hFile))
		{
			char * szOffset = strtok(szStr, " \t"),
				 * szName = strtok(NULL, " \t");
			
			int offset = StringToInt(szOffset);

			CLabel *pLabel = CLabels::Add(szName, offset);
			CLabels::IndexName(pLabel);
		}
		CloseFile(hFile);
		return true;
	}
	else throw(SCRambl.BuildText(SCRambl.GetText("GENERAL", "OERR"), NULL, 0, "%s", szFilePath));
	return false;
}